package com.course.base;

public class Teacher extends Person {

    private Course taughtCourse; // 所授课程

    // 子类构造方法：通过super()调用父类构造
    public Teacher(String teacherId, String name, String gender) {
        super(teacherId, name, gender); // 调用父类的构造方法
    }

    // 教师“开课”方法
    public void openCourse(Course course) {
        this.taughtCourse = course;
        System.out.println("教师[" + super.name + "]成功开设课程：" + course.getCourseName());
    }

    // 重写父类的printSheet：打印教师课表
    @Override
    public void printSheet() {
        super.printSheet(); // 调用父类的printSheet
        if (taughtCourse != null) {
            System.out.println("所授课程：" + taughtCourse.getCourseName());
            System.out.println("上课地点：" + taughtCourse.getLocation());
            System.out.println("上课时间：" + taughtCourse.getTime());
        } else {
            System.out.println("暂未开设课程");
        }
        System.out.println("======================\n");
    }

    // getter方法（供Student类调用）
    public Course getTaughtCourse() {
        return taughtCourse;
    }
}
